<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Log extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->library('Mydatetime');
		$this->load->library('session');
		$this->load->model('log/log_model');
        
        $this->load->language('log/log', 'vietnam');
        $this->load->language('common', 'vietnam');
	}
	
	function _loadHeader($title = '')
	{
		$header = array();
		$header['title'] = $title;
		
		$header['username'] = '';
		$header['userid'] = '';
		$header['access'] = '';
        
		if($this->session->userdata('uname'))
		{
			$header['username'] = $this->session->userdata('uname');
			$header['userid'] = $this->session->userdata('uid');
			$header['access'] = $this->session->userdata('access');
		}
		
		$this->load->view('header_view', $header);
	}
    
	function _loadLeftmenu()
	{
        $data = array();
        $common_lang = $this->lang->line('common_lang');
        $data['common_lang'] = $common_lang;
		$this->load->view('leftmenu_view', $data);
	}
	
	function _loadFooter()
	{
		$this->load->view('footer_view');
	}
	
    function index()
	{
	   
        if(!$this->session->userdata('username'))
        {
            redirect(site_url('login'));
            die();
        }
        $data = array();
        $uid = $this->session->userdata('uid');
        $log_lang = $this->lang->line('log_lang');
        $data['log_lang'] = $log_lang;
        $numrow = (int)$this->input->get('numrow') > 0 ? (int)$this->input->get('numrow') : 20;
        $page = (int)$this->input->get('page') > 0 ? (int)$this->input->get('page') : 1;
        $data['st'] = $type_st = 0;
        $users = $this->contact_model->ww_get_list_user($type_st, $numrow, $page);
        
        $items = $users['items'];
        $total = $users['total'];
        
        $data['info'] = $items;
        $data['total'] = $total;
        $data['current_page'] = $page;
        $data['max_page'] = ceil((int)$data['total']/$numrow);
        
        // header
        $this->_loadHeader('Góp ý nội dung');
        
        // leftmenu
        $this->_loadLeftmenu();
        
        // content
        $this->load->view('log/lst_log_view', $data);
        
        // footer
    }
}